#!/usr/bin/perl 

use strict;
use DBI;
use CGI;
use TTraker;

my $dbh;
& initialize_dbi;
& print_header;

my $form_ref = parse_input();
my %FORM_DATA = %$form_ref; 
my $supNum = $FORM_DATA{'supNum'};
my $supName = $FORM_DATA{'supName'};
my $supJob = $FORM_DATA{'supJob'};
my $supLoc = $FORM_DATA{'supLoc'};
my $empNum = $FORM_DATA{'empNum'};
my $empName = $FORM_DATA{'empName'};
my $payDate = $FORM_DATA{'payDate'};
my $jobNum = $FORM_DATA{'jobNum'};
my $i = 0;
my $taskNum;

foreach my $key (keys %FORM_DATA) {
  if ($key =~ /^TASK_/ ) {
    my $task = $key;
    $task =~ s/TASK_//;
    my $value = $FORM_DATA{$key};
     if ( $value =~ /^\d+(\.\d{1,4})?$/ || $value =~ /^\.\d{1,4}$/ ) {
     		$i ++;
     		if ($i == 1 ) { 
     			$taskNum = get_new_count('TASK');
     		}
     		adjust_tmp_task_table ($supNum, $empNum, $payDate, $jobNum, $task, $value, $taskNum);
    }	
  }
}

write_task_changes ($supNum, $empNum, $payDate, $jobNum);

update_job_headers_with_time ($jobNum);

sup_activity_screen_from_pm ($supNum, $supName, $supJob, $supLoc, ""); 

# trak_02_sup_activity_selection ($supNum, $supName, $supLoc);

db_disconnect();

##################### SUBROUTINES FOLLOW  #####################

sub trak_02_sup_activity_selection
{
my $supNum = $_[0];
my $supName = $_[1];
my $supLoc = $_[2];

my $week_ref = get_payroll_review_weeks;
my @weeks = @$week_ref;
# print "HEY $weeks[0][0] - $weeks[0][1] : $weeks[1][0] - $weeks[1][1] : $weeks[2][0] - $weeks[2][1] <br/>";
my $msg = & get_message ($supNum);
# my @dis = & get_disabled_list ($num);
# my @col = & get_dimmed_list ($num);
my @dis = ("", "", "", "", "", "", "", "","","disabled=\"disabled\"");
my @col = ("dis","en","en","en","en","en","en","en", "en", "dis"); 

print <<ENDHEADER;
<html>
<head>
<link rel='stylesheet' type='text/css' href='${css_ref}trak.css' />
<script type='text/javascript' src='${js_ref}trak.js'></script>
<title>trak_02_sup_activity_select</title>
</head>
<body onload='startTime()'>
<h2><center>${banner}</center></h2>
<hr/>
<div id='clock'></div>
<div id='box1'>
Employee Number: <br/><br/>
Employee Name: <br/><br/>
Activity:
</div>
<form id='box2' autocomplete='off' name='activity' action='${cgi_ref}trak_02_sup_activity.pl' method='post'>
<input type="hidden" name=empNum value='$supNum'/>
<input type="hidden" name=empName value='$supName'/>
<input type="hidden" name=empJob value='SUP'/>
<input type="hidden" name=empLoc value='$supLoc'/>
<span>$supNum</span><br/><br/>
<span>$supName</span></b><br/><br/>
<input $dis[1]type="radio" name="activity" value="1" checked="checked"/>&nbsp<$col[1]> Confirm Daily Payroll</$col[1]><br/>
<input $dis[2]type="radio" name="activity" value="$weeks[0][0]"/>&nbsp<$col[2]> Review Payroll - $weeks[0][1] </$col[2]><br/>
<input $dis[3] type="radio" name="activity" value="$weeks[1][0]"/>&nbsp<$col[3]> Review Payroll - $weeks[1][1] </$col[3]><br/>
<input $dis[4] type="radio" name="activity" value="$weeks[2][0]"/>&nbsp<$col[4]> Review Payroll - $weeks[2][1]</$col[4]><br/>
<input $dis[5] type="radio" name="activity" value="5"/>&nbsp<$col[5]> Add New Temp Employee</$col[5]><br/>
<input $dis[6] type="radio" name="activity" value="6"/>&nbsp<$col[6]> Who is logged in?</$col[6]><br/>
<input $dis[7] type="radio" name="activity" value="7"/>&nbsp<$col[7]> Enter Data from Time Cards</$col[6]><br/>
<input $dis[8] type="radio" name="activity" value="8"/>&nbsp<$col[8]> Modify Tasks for Individulal Jobs </$col[7]><br/>
<input $dis[9] disabled="disabled" type="radio" name="activity" value="9"/>&nbsp<$col[9]> TBA</$col[9]><br/>

<br/>
<input type='submit' value='Proceed'>
<br/><br/>
<a href="${cgi_ref}trak_00_start_up.pl">Return to Log-In</a>
<br/><br/>
</form>
</body>
</html>

ENDHEADER
}

